﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeadMaster.Models;
using LeadMaster.DAL;
using LeadMaster.Helpers;

namespace LeadMaster.Controllers
{
    public class InvoicingController : Controller
    {
        private DunsmoreContext db = new DunsmoreContext();

        //
        // GET: /Invoicing/

        public ActionResult Index()
        {
          Maintenance.inMaintenance = true;
          return View(db.Invoicing.ToList());
        }

        //
        // GET: /Invoicing/Details/5

        public ActionResult Details(int id = 0)
        {
            Invoicing invoicing = db.Invoicing.Find(id);
            if (invoicing == null)
            {
                return HttpNotFound();
            }
            return View(invoicing);
        }

        //
        // GET: /Invoicing/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Invoicing/Create

        [HttpPost]
        public ActionResult Create(Invoicing invoicing)
        {
            if (ModelState.IsValid)
            {
                db.Invoicing.Add(invoicing);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(invoicing);
        }

        //
        // GET: /Invoicing/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Invoicing invoicing = db.Invoicing.Find(id);
            if (invoicing == null)
            {
                return HttpNotFound();
            }
            return View(invoicing);
        }

        //
        // POST: /Invoicing/Edit/5

        [HttpPost]
        public ActionResult Edit(Invoicing invoicing)
        {
            if (ModelState.IsValid)
            {
                db.Entry(invoicing).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(invoicing);
        }

        //
        // GET: /Invoicing/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Invoicing invoicing = db.Invoicing.Find(id);
            if (invoicing == null)
            {
                return HttpNotFound();
            }
            return View(invoicing);
        }

        //
        // POST: /Invoicing/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            Invoicing invoicing = db.Invoicing.Find(id);
            db.Invoicing.Remove(invoicing);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}